package factory;

import dao.NewsDao;
import dao.impl.NewsDaoImpl;
import dao.impl.NewsDaoMySqlImpl;
import dao.impl.NewsDaoOracleImpl;
import dao.impl.NewsDaoRedisImpl;

public class SimpleDaoFactory {
    public static NewsDao getInstance(){
        return new NewsDaoImpl();
    }
    public static NewsDao getInstance(String key){
        // return new NewsDaoImpl()
        if (key.equals("mysql")) {
            return new NewsDaoMySqlImpl();
        } else if (key.equals("oracle")) {
            return new NewsDaoOracleImpl();
        } else if (key.equals("redis")) {
            return new NewsDaoRedisImpl();
        }else {
            throw new RuntimeException("无效的数据库类型："+key+",DAO获取失败");
        }
    }
}
